/**
 * Created by yuris on 10.12.14.
 */
package ShopObjects {
import starling.display.Image;

public class DoorView extends AbstractGameObjectView {
    private var _model:int;
    private var _doorImage:Image = null;
    private var fullImageName:String;
    public function DoorView(fullImageName:String) {
        super();
        this.fullImageName = fullImageName;

        this._model = int(fullImageName.split("/Door").pop());

        this._doorImage = GraphicFactory.getImageByName(fullImageName);
        this.addChild(this._doorImage);

    }

    public function set opened(value:Boolean):void {
        this._doorImage.scaleX = value?-1:1;
    }
    public function get opened():Boolean {
        return Boolean(this._doorImage.scaleX == -1);
    }

    override public function get typemodel():String {
        return "d"+this._model;
    }

    override protected function _onRotate45():void{
        this.scaleX = 1;
    }
    override protected function _onRotate135():void{
        this.scaleX = -1;
    }
    override protected function _onRotate225():void{
        this.scaleX = 1;
    }
    override protected function _onRotate315():void{
        this.scaleX = -1;
    }

    public function get doorImage():Image {
        return _doorImage;
    }
}
}
